package com.karson.front.controller;

import com.karson.common.model.Subtitles;
import com.karson.common.response.CommonResult;
import com.karson.common.response.TrackResponse;
import com.karson.service.service.SubtitlesService;
import com.karson.service.service.TrackInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZKS
 */
@RestController
@RequestMapping("/api/track")
@Tag(name = "歌曲管理接口")
public class TrackController {
    @Autowired
    private TrackInfoService trackInfoService;
    @Autowired
    private SubtitlesService subtitlesService;
    @Operation(summary = "根据专辑查询音声信息")
    @GetMapping("/list/{albumId}")
    public CommonResult<List<TrackResponse>> getList(@PathVariable("albumId") Integer albumId) {
        List<TrackResponse> trackResponses = trackInfoService.getTrackInfo(albumId);
        return CommonResult.success(trackResponses);
    }
    @Operation(summary = "获取对应字幕文件")
    @GetMapping("/subtitle/{trackId}")
    public CommonResult<Subtitles> getSubTitle(@PathVariable("trackId") Integer trackId) {
       Subtitles subtitles = subtitlesService.getSubtitleByTrackId(trackId);
       return CommonResult.success(subtitles);
    }
}
